#ifndef UTILITY_H
#define UTILITY_H

/*
 *  utility.h
 *  
 *
 *  Created by Jason Hsu on 12/8/09.
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
 *
 */

#include "util/color4f.h"
#include <time.h>


class Utility
{
public:
	static void enableOutlining(Color4f outlineColor, GLfloat lineWidth)
	{
		glEnable(GL_CULL_FACE);								// Enable face culling
		glEnable (GL_BLEND);								// Enable Blending
		glBlendFunc (GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA);	// Set blend mode
		glPolygonMode (GL_BACK, GL_LINE);					// Draw Backfacing Polygons As Wireframes
		glLineWidth (lineWidth);							// Set The Line Width
		glCullFace (GL_FRONT);								// Don't Draw Any Front-Facing Polygons
		glDepthFunc (GL_LEQUAL);							// Change The Depth Mode
		glColor3f(outlineColor[0], outlineColor[1], outlineColor[2]);			// Set The Outline Color
	}
	
	static void disableOutlining()
	{
		glDepthFunc (GL_LESS);				// Reset The Depth-Testing Mode
		glCullFace (GL_BACK);				// Reset The Face To Be Culled
		glDisable(GL_CULL_FACE);			// Disable face culling
		glPolygonMode (GL_BACK, GL_FILL);	// Reset Back-Facing Polygon Drawing Mode
		glDisable (GL_BLEND);				// Disable Blending
	}
	
	static void switchToOrtho()
	{
		glMatrixMode(GL_PROJECTION);
		glPushMatrix();
		glLoadIdentity();
		
		glOrtho(-75.0f, 75.0f, -15.75, 15.75, 0.1, 500.0);
		
		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glLoadIdentity();
	}
	
	static void switchToProj()
	{
		glMatrixMode(GL_PROJECTION);
		glPopMatrix();
		
		glMatrixMode(GL_MODELVIEW);
		glPopMatrix();
	}
	
	static struct tm *getTime()
	{
		time_t rawTime = time(&rawTime);
		return localtime(&rawTime);
	}
};

#endif
